<template>
  <div>
    <div>【大区数据信息】</div>
    <div ref="target" class="w-full h-full"></div>
  </div>
</template>
<script setup>
import { ref, onMounted } from "vue";
import * as echarts from "echarts";
const props = defineProps({
  data: {
    type: Object,
    required: true,
  },
});
console.log(props.data);
// 1.初始化echarts实例
let mChart = null;
const target = ref(null);
onMounted(() => {
  mChart = echarts.init(target.value);
  renderChart();
});
// 2.构建option配置对象
const renderChart = () => {
  const options = {
    // X轴展示数据
    xAxis: {
      show: false,
      type: "value",
      max: function (value) {
        return parseInt(value.max * 1.2);
      },
    },
    // Y轴展示数据
    yAxis: {
      type: "category",
      data: props.data.regions.map((item) => item.name),
      inverse: true,
      axisLine: {
        show: false,
      },
      axisTick: {
        show: false,
      },
      axisLabel:{
        color:'#9eb1c8'
      }
    },
    // 图标绘制的位置，对应上下左右
    grid: {
        top:0,
        right:0,
        bottom:0,
        left:0,
        containLabel:true
    },
    // 核心配置
    series: [
        {
            type:'bar'
        }
    ],
  };
  mChart.setOption(options);
};
// 3.通过 实例.setOptions(option)
</script>

<style lang="scss" scoped>
</style>
